package com.xbts.web.controller.manager;

import com.xbts.common.annotation.Log;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.core.page.TableDataInfo;
import com.xbts.common.enums.BusinessType;
import com.xbts.system.domain.CnHwyTemplate;
import com.xbts.system.domain.dto.CnHwyTemplateTopDTO;
import com.xbts.system.service.ICnHwyTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author : llk
 * @Date: 2024/4/10 10:56
 */
@Api(tags = "华为云模板管理")
@RequestMapping("/manager/hwy_template")
@RestController
public class ManagerHwyTemplateController extends BaseController {

    @Resource
    private ICnHwyTemplateService hwyTemplateService;

    /**
     * 获取华为云模板列表
     */
    @ApiOperation("获取华为云模板列表")
    @GetMapping("/list")
    public TableDataInfo list(String name){
        startPage();
        return getDataTable(hwyTemplateService.listData(name));
    }

    /**
     * 新增华为云模板
     */
    @ApiOperation("新增华为云模板")
    @Log(title = "华为云模板", businessType = BusinessType.INSERT)
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody CnHwyTemplate cnHwyTemplate) {
        return toAjax(hwyTemplateService.insertCnHwyTemplate(cnHwyTemplate));
    }

    /**
     * 修改华为云模板
     */
    @ApiOperation("修改华为云模板")
    @Log(title = "华为云模板", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult update(@RequestBody CnHwyTemplate cnHwyTemplate) {
        return toAjax(hwyTemplateService.updateCnHwyTemplate(cnHwyTemplate));
    }

    /**
     * 批量删除华为云模板
     */
    @ApiOperation("批量删除华为云模板")
    @Log(title = "华为云模板", businessType = BusinessType.DELETE)
    @DeleteMapping("/batchDelete/{ids}")
    public AjaxResult batchDeleteContent(@PathVariable List<Long> ids) {
        return toAjax(hwyTemplateService.batchDeleteContentById(ids));
    }

    /**
     * 置顶华为云模板
     */
    @ApiOperation("置顶华为云模板")
    @Log(title = "华为云模板", businessType = BusinessType.UPDATE)
    @PostMapping("/top")
    public AjaxResult top(@Valid @RequestBody CnHwyTemplateTopDTO topDTO) {
        return toAjax(hwyTemplateService.top(topDTO));
    }
}
